<template>
  <div class="page-containers" :style="{height:HEIGHT+'px'}">
    <!--工具栏-->
    <div class="toolbar">
      <el-form :inline="true" :model="filters" :size="size" ref="filters">
        <el-row class="search-input">
          <el-form-item label="标签名称：">
            <el-input v-model="filters.ruleNum" placeholder="输入标签名称" clearable></el-input>
          </el-form-item>
        </el-row>
        <el-row class="search-input">
          <el-form-item label="所属组织名称：">
            <el-input v-model="filters.ruleNum" placeholder="输入所属组织名称" clearable></el-input>
          </el-form-item>
        </el-row>
        <el-row class="search-input">
          <el-form-item label="组织层级：">
            <el-select v-model="filters.changeTypes"  placeholder="全部" clearable>
              <el-option label="母平台" value="1"></el-option>
              <el-option label="子平台" value="2"></el-option>
              <el-option label="商家" value="3"></el-option>
            </el-select>
          </el-form-item>
        </el-row>

        <div class="w100 t_r mb30">
          <el-form-item class="noMargin">
            <kt-button icon="el-icon-search" :label="'搜索'" type="primary" @click="findPage(null)"/>
          </el-form-item>
          <el-form-item class="noMargin">
            <el-button   @click="resetForm('filters')" type="primary" plain>重置</el-button>
          </el-form-item>
        </div>
      </el-form>
    </div>
    <div class="toolbar" >
      <table-column-filter-dialog
        ref="tableColumnFilterDialog"
        :columns="columns"
        @handleFilterColumns="handleFilterColumns"
      ></table-column-filter-dialog>
    </div>
    <!--表格内容栏-->
    <cy-table :height="350" :data="pageResult" :columns="filterColumns"   @selectionChange="selectionChange"
              :showBatchDelete="false" showDetailOperation :showDeleteOperation="false" :showPushOperation="false"
              :showOperation="false"
              :showSelection="false"
              ref="CyTable">
    </cy-table>
  </div>
</template>

<script>
  import {exportExcel} from "@/utils/excel";
  import CyTable from "@/views/Core/JicTable";
  import KtButton from "@/views/Core/KtButton";
  import {format} from "@/utils/datetime";
  import TableColumnFilterDialog from "@/views/Core/TableColumnFilterDialog";
  import {validatePhone,validateContacts,isEmail,isNumber} from '@/utils/validate'
  import XLSX from "xlsx";
  export default {
    components: {
      CyTable,
      KtButton,
      TableColumnFilterDialog,
    },
    data() {
      return {
        HEIGHT:window.innerHeight,
        startTime:null,
        endTime:null,
        id:this.$route.params.id,
        thirdUserId:this.$route.params.id,
        businessId:"",
        deptMsg:localStorage.getItem('user'),//当前登录组织信息
        userId:localStorage.getItem("userId"),//当前登录用户id
        deptType:localStorage.getItem("deptType"),//当前登录用户所属组织类型
        createTime:null,
        changeMode:null,
        changeTypes:null,
        integralType:null,
        deptName:null,
        deptOption:[],
        content: null,
        size: "small",
        filters: {
        },
        columns:[
          { label: "标签名称", minWidth: 130},
          { label: "所属组织", minWidth: 120},
          { label: "组织层级", minWidth: 120},
          { label: "打标时间", minWidth: 120},
        ],
        filterColumns: [],
        pageRequest: {pageNum: 1, pageSize: 10},
        pageResult: {},
        value:0,
        printPage:false,
        editLoading: false,
        reviewFormRules: {

        },
        checked: [],
        statusList: []
      };
    },
    methods: {
      // 获取分页数据
      // findPage: function(data) {
      //   if(data != null && data.start != null){
      //     if(data.start != null){
      //       this.pageRequest.pageNum = data.start;
      //     }
      //     if(data.limit != null){
      //       this.pageRequest.pageSize = data.limit;
      //     }
      //   }
      //   let this_ = this;
      //   if (this_.filters == undefined || this_.filters == null) {
      //     this_.filters = {};
      //   }
      //   this_.filters.start = this.pageRequest.pageNum;
      //   this_.filters.limit = this.pageRequest.pageSize;
      //   this.utils.request.findIntegralInfo(this_.filters, function (res) {
      //     if (res.data == null) {
      //       res.data = [];
      //       res.totle = 0;
      //     }else{
      //       this_.$refs.CyTable.findPage({content:res.data.rows,total:res.data.total});
      //     }
      //   });
      // },

      //获取子平台列表
      queryDeptOption(){
        let query={}
        let this_=this
        this_.utils.request.queryChildList(query,function(res){
          if(res.code == '0000'){
            this_.deptOption=res.data
          }
        })
      },
      //获取选择框数据
      selectionChange(val) {
        this.checked = val.selections;
      },

      // 时间格式化
      dateFormat: function (row, column, cellValue, index) {
        return format(row[column.property]);
      },

      resetForm(formName) {
        if (this.$refs[formName] != undefined) {
          this.$refs[formName].resetFields();
          this.filters={};
          //this.findPage(null);
        }
      },

      // 处理表格列过滤显示
      displayFilterColumnsDialog: function () {
        this.$refs.tableColumnFilterDialog.setDialogVisible(true);
      },
      // 处理表格列过滤显示
      handleFilterColumns: function (data) {
        this.filterColumns = data.filterColumns;
        this.$refs.tableColumnFilterDialog.setDialogVisible(false);
      },
      // 处理表格列过滤显示
      initColumns: function () {
        var temp = [];
        $.each(this.columns, function (key, val) {
          temp.push(val);
        });
        this.filterColumns = temp;
      },
    },
    mounted() {
      this.initColumns()
      //this.findPage()
      this.queryDeptOption();

    }
  };
</script>

<style lang="scss" scoped>
  .reset {
    background-color: #fff;
    color: #2F4554;
  }
  .noMargin{
    margin-right: 0 !important;
    margin-bottom: 0 !important;
  }
</style>
